SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE view [dbo].[entre35y50]
as
select distinct tb_localidades.localidad, count(*) as entre35y50 from tb_agentes a 
inner join tb_localidades on a.localidad = idlocalidad 
where documento in(select distinct documento from Tb_LicenciasEntreFechasDeTodosLosAgentes2007 where dias > 0 )
and documento between  13000000 and 22999999 
group by tb_localidades.localidad 

GO
